package com.lpf.nio;

import java.nio.ByteBuffer;

/**
 * 功能描述：ByteBuffer中型化的get put方法
 *
 * @author lpf
 * @date 2019/11/25 16:19
 * @version: 1.0
 **/
public class NioTest05 {

    public static void main(String[] arg) {
        ByteBuffer buffer = ByteBuffer.allocate(64);

        buffer.putInt(15);
        buffer.putLong(500000000000L);
        buffer.putDouble(14.123456);
        buffer.putChar('你');
        buffer.putShort((short) 2);
        buffer.putChar('我');

        buffer.flip();

        // 取出的时候要按照放入（类型）的顺序取，否则会报错

        System.out.println(buffer.getInt());
        System.out.println(buffer.getLong());
        System.out.println(buffer.getDouble());
        System.out.println(buffer.getChar());
        System.out.println(buffer.getShort());
        System.out.println(buffer.getChar());

    }
}




